﻿#ifndef ACCESS_H
#define ACCESS_H

#include <QObject>
#include <QtWebSockets/QWebSocket>
#include <QTimer>
#include <QNetworkReply>
#include "oeasycommon.h"
#include "ipc.h"
#include <time.h>

class Access : public QObject
{
    Q_OBJECT
public:
    explicit Access(QList<IPC *> &ipcList, QString &url, QString &id, QString &faceEnterUrl, QObject *parent = 0);
    ~Access();

private:
    QWebSocket m_ws;
    QNetworkAccessManager m_faceEnterManager;
    QString &m_faceUrl;
    QString &m_url;
    QString &m_id;
    QList<IPC *> &m_ipcList;
    QTimer m_heartbeatTimer;
    time_t m_MotionTime;

signals:
    void textRecv(QString);

public slots:
    void onConnected();
    void onHeartbeatTimeout();
    void onTextMessageReceived(QString);
    void onError(QAbstractSocket::SocketError);
    void onFaceEnterFinished(QNetworkReply *r);
};

#endif // ACCESS_H
